import React, { Component } from 'react';
import axios from 'axios';
import { Table } from 'antd';
class DemoList extends Component {
    constructor(props){
        super(props);
        this.state={
            groupList:[],
            isLoaded:false,
            columns:[
                {
                    title: '编号',
                    dataIndex: 'uid'
                },
                {
                    title: '类型',
                    dataIndex: 'type'
                },
                {
                    title: '名称',
                    dataIndex: 'group_name'
                }
            ]
        }
    }
    componentDidMount(){
        var _this = this;
        axios.get('http://127.0.0.1:3000/api/demo/groupList')
            .then(function (response) {
                console.log(response.data.data)
                _this.setState({
                    groupList:response.data.data,
                    isLoaded:true
                });
            })
            .catch(function (error) {
                console.log(error);
            });

    }

    render() {
        if(!this.state.isLoaded){
            return <div>Loading</div>
        }else{
            return (
              <Table dataSource={this.state.groupList} columns={this.state.columns}/>
            )
        }
    }
}

export default DemoList;
